<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Mess_mdl extends MY_Model {

    public function __construct() {
        parent::__construct();
        $this->table = 'mess';
    }

    /**
     * 发送消息
     */
    public function send_message($mess,$receive = ''){
        $receive = empty($receive) ? $_SESSION['user']['id'] : $receive;
        $data = array(
            'sending' => 1,
            'receive' => $receive,
            'content' => $mess,
            'create_time' => $_SERVER['REQUEST_TIME'],
            'status' => '1'
        );
        return $this->create($data);
    }

    /**
     * 管理员通知
     */
    public function send_admin($mess){
        $this->load->model('users_mdl');
        $this->db->where('status !=',3);
        $this->db->select('id');
        $users = $this->users_mdl->select();
        foreach($users as $k => $v){
            $this->send_message($mess,$v['id']);
        }
        return true;
    }

}

/* End of file Mess_mdl.php */
/* Location: ./application/models/Mess_mdl.php */